package cn.zust.ly.EyExample.Ey11;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		
		char[] strChar = str.toCharArray();
		int len = strChar.length;
		int sum = 0;
		
		//System.out.println(str);
		for (int i = len-1; i >=0 ; i--) {
			sum += getIntByChar(strChar[i]) * Math.pow(16, len-1-i);
			//System.out.println(strChar[i] + "---" + sum);
		}
		System.out.println(sum);
		
		
		
	}
	static int getIntByChar (char c) {
		if((int)c < 54 ) return (int)(c-48);
		else return (int) (c-55);
	}
}
